package cn.blackjuly.cadmin.util;

/**
 * 判断web服务器类型
 */
public class ServerUtil {
    private static final String JETTY_CLASS = "/org/eclipse/jetty/server/Server.class";
    private static final String TOMCAT_CLASS = "/org/apache/catalina/startup/Bootstrap.class";

    /**
     * @return 返回当前运行的服务器名称，目前只支持tomcat和jetty
     */
    public static String getServerName() {
        Class clazz = ServerUtil.class;
        if (clazz.getResource(JETTY_CLASS) != null) {
            return "Jetty";
        } else if (clazz.getResource(TOMCAT_CLASS) != null) {
            return "Tomcat";
        } else {
            return "Unknown";
        }
    }
}
